Linen is an important textile product which has been used for years. The first usage of linen dates back to old times. People started to use linen almost 10,000 years ago. Flax plant fibers, linum usitatissimum are raw materials that are used to produce linen. People use linen for preparing lots of different items such as canvases, clothing, bedding, wallpaper, towels etc. The usage areas of the linen are quite wide. For instance, Egyptians used linen for items that necessitates strength like skirts and pants of Medieval knights.
In general linen is accepted as a luxury item although at first sight, it does not make sense to price linen higher than the other textile products. On the other hand, if the production process of linen is analyzed the higher price situation makes sense. (About Linen)
Due to the fact that the defects on the surface of textile product decrease the quality of the clothing, inspection of the fabric during the production process has high importance. If the defects can be determined during the production process, the problem will be fixed in much easier and less costly. Moreover, as linen is a quite expensive textile product, monitoring the linen processing is significant. If the defects cannot be identified in that processing interval, fixing the problem becomes way more time consuming and costly. However, there is a problem about identifying those defects. In general the defects on the fabrics are too small to realize just by inspection. People cannot identify the defects “just by the first and second order statistical features of the image. (Tong, Le, et al.) That is why some other techniques must be used in order to identify those defects.
Preprocessing can be utilized in order to detect the defects. Gabor filtering is one of the techniques that can be used for preprocessing. Furthermore, this technique is used for preprocessing the images in Project Part 3. The usage of Gabor filtering results in considerable decrease in the input image signal and the influence of noise. Moreover, after Gabor filtering a reduction in the contrast between defects and textile product background is provided. That situation ease the identifying process of the defects in the linen.
According to the traditional analysis methods, detecting the defects does not have any importance. Traditional methods focus on providing the textile product features of high quality. “Traditional texture analysis methods are more concerned with the problem of extracting textural features than with the problem of detecting local variations associated with a class of small defects. In these cases, the contribution of the defect to any statistic computed using all the pixels in the image is expected to be small, and, therefore, statistics based on the whole image are not expected to be powerful.” (Benito)
In order to select the method some research related to the defect detection were conducted. There are different kinds of methods to detect the defects. After the research different kinds of approaches were decided. These approaches can be classified as statistical, spectral, model-based, learning, structural and others. Statistical approaches are: Auto-correlation function, Co-occurrence matrix, Mathematical morphology, Fractal method; Spectral approaches are: Fourier transform, Wavelet transform, Gabor transform, Filtering approach; Model based approaches are Autoregressive model, Markov random fields; and Neural networks is the learning approach(H.Y.T. Ngan et al.). Each method were analyzed separately. After detailed analyzation about finding the best method that suit the task one approach was selected. The course knowledge and the ideas which were gathered with research were combined and determined that Gabor approach is the best approach to reach the aim in that project.
In statistical approach, spatial distribution of pixel values were observed. An important assumption in this approach is that the statistics of defect free regions are stationary, and these regions extend over a significant portion of inspection images(Mahajan, Patil and Kolhe). Statistical approaches are grouped according to the number of pixels of the image; first order and higher orders. There are some significant differences between these statistics. Spatial interaction is ignored in the first order statistics; on the other hand, higher order statistics consider the interaction between image pixels. There are different methods that can be used in the statistical approach. Auto-correlation function, Co-occurrence matrix, Mathematical morphology, Fractal methods are considered as the statistical approaches.
Auto-correlation function: Auto-correlation function is one of the statistical approaches that can be used to detect the defects on the fabric. This method finds the unit replication on the image by searching for the translational and rotational symmetry. On the other hand, this method cannot be interpreted as a good method since this method necessitates a reference frame to detect the defects. Moreover, sometimes it can misread the signals in the fine texture.
Co-occurrence matrix: Another statistical method is co-occurrence matrix. It was suggested by Haralick. The spatial features of the CM are superior to that of AF because the cooccurrence probabilities can extract more information in one spatial distance, which is the measure between two pixel locations(H.Y.T. Ngan et al.). However, this method cannot be accepted as a reliable method since it was not applied to different kinds of fabrics. Moreover, it requires intensive computer calculations and it does not work well in large-size textures.
Mathematical morphology: Mathematical morphology is another statistical method for detecting defects. Nonlinear techniques are used in that method. This method conduct some operations in order to smooth, sharpen and remove the noise from the image. The examples for that operations are erosion and dilation. Illumination and distance between camera and fabric are accepted as one of the important factors in detecting defects in that method. Although it seemed reliable, no discussion was given for fabrics of other wallpaper groups(H.Y.T. Ngan et al.). There are some important drawbacks of that method. Some examples for the cons of that method can be that method is quite sensitive to the shape and size of the defect, moreover it is more localized.
Fractal method: Fractal method was introduced by Pantland. Box-counting process is used in that approach. It is based on finding the probability that a point is whether or not can be found in the box. There are different fractal methods. They are suitable for modeling self-similarities and roughness on the surfaces. Moreover, this method is not suitable to detect defects correctly, since the false alarm risk is very high and the location of the defects are not accurate. Furthermore, limited experimental results were observed.
Process monitoring on linen has always been vital for quality control. As a raw material of textile sector, quality of linen as well as other fabrics are directly linked with profitability and the quality of the products. Defects of linen usually has some pattern. Most common ones are as follows: weft curling, holes, stitching and knots. To defect and remove these problematic parts on linen, lots of methods were used and still being upgraded. Inspection methods can be classified in 2 main clusters: Human based and Automated.
Human based inspection systems uses human eye as the control unit. Since automated systems requirements are highly technology dependent, expensive and not eligible for all producers, human based inspection is still very common. The idea behind is very simple, produced linen is hung on a plain surface and inspector find the defects on the linen. If similar errors are continuous during the production process, inspector warns the production unit. Since whole inspection is done by humans, this traditional method has some major drawbacks. First of all human performance can never be stable during the inspection period so %100 success in detection is never achieved by this method. Also humans are much slower than automation thus it takes more time to detect.
Second cluster is Automated Inspection System. This method is more stable and has higher precision on inspection. Also labour costs disappear with this approach however initial investment is high, especially software and hardware costs.
One important approach that is commonly used is spectral (signal processing based) approach. Spectral approaches uses computer vision to find defects. Theory of all these approaches is based on the extraction of the primitives of textures, thus when there is randomness in the texture these methods fail to work precisely but at other times, these methods are efficient. In that project one of the spectral methods which is Gabor Transform will be used.
Fourier Transform: Roots of this method is based on Fourier Series. Fourier Transform uses the frequency to find defects. The FT characterizes the textured image in terms of frequency components. The periodically occurring features can be observed from the magnitude of frequency components. These global texture patterns are easily distinguishable as concentration of high-energy bursts in the spectrum.”(Mahajan, Patil and Kolhe) This approach is very suitable and efficient in detecting periodical and patterned defects. On a magnitude spectrum; size, shape and distribution of defects are reflected, so inspection is possible Drawbacks of this method appears when there is a random pattern(also non-symmetricity) on linen. Also when defects are large, sometimes this method misinterprets the process.
Wavelet Transform: Wavelet Transform uses multiresolution decomposition as based and find defects this way. In simpler terms, this method is good at recognizing local patterns and compare them with near portions. This method enables to observe nearly all features of defects. This method is extremely efficient around %98 however it has very complex iterations cause adaptive wavelet transform is very hard to iterate.
Gabor Transform: Gabor Transform method is one of the most used methods in defect detection. As stated, Fourier Transform uses frequency distribution on the image as a whole. When the window size in set as Gaussian function, the windowed Fourier Transform is called Gabor Transform. In simpler terms, Gabor Transform helps us to analyze any frequency change in the texture in any direction and region. When Gabor Transform is used on a texture, defects become more visible and clear due to characteristics of this transform. To apply Gabor Transform there are some parameters to set beforehand, especially selecting true angles for transform is vital for a successful transform. Also this method eliminates the autocorrelation of the pixels. Parameter selection is the crucial part of Gabor filter application and defect detection. The parameters include, lambda, theta, bandwidth, phi and aspect ratio(Refer Appendix I).
The parameters are manually adjusted for each image for linen defects. The use of Gabor filter can be the first step of the machine learning. Due to the limited picture image set of size 20, it was not possible to train the data set however this can be the first step for the training.
In the Project Part-3, the task is to detect the defects in the given fabric images. After converting the images on the greyscale there are some methods that can be used to detect the defects on the fabric images. After some researches about the methods, Gabor filter was selected as the most suitable method for finding the defects.The idea was using Gabor filter in order to remove the autocorrelation between pixels in each fabric image.
Gabor filter is a good method in order to reach optimum localisation in the spatial domain. It is significant in visual inspection. This is the first step in order to detect the defects. After that step the 512*512 images were divided into 32*32 squares. The inspections were conducted in that small squares. The upper and lower control limits were detected for each small square and the control charts were prepared for each small square. 2 sigma limit is used for preparing the upper and lower control limits. X bar charts were designed and the outliers were accepted as the point defects in the fabrics. In the code the outlier points were given as a number that represent points in the original image. This control process was conducted for each 20 images and the results were recorded. After this control process it was realized that the method works well enough in detecting defects. Of course there are some small errors regarding the finding the defects; however, in general these are small issues. Method works as expected.
IMAGE 1
library(jpeg)
library(wvtool)
img<-readJPEG("~/Desktop/Fabric1.jpg")
greyimg<-img[,,1]
filtered_image<-gabor.filter(greyimg,30,0,3,0,1,TRUE)
array<-rep(NA)
newimage<-filtered_image$filtered_img
for(i in 1:16){
for(j in 1:16){
array[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
256 windows are created after applying the Gabor filter. The mean of each window is calculated. The window size is 32 x 32 . There are 16 windows in each row.
CL<-mean(array)
UCL<-CL+2*sd(array)
LCL<-CL-2*sd(array)
plot(array, type="l",ylim = c(min(array),max(array)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
The x-bar control chart is prepared with the mean of each window. The out of control situations are shown in the chart. The control limits are identified at 2 sigma level, since linen is sensitive product.
defect<-rep(0)
u<-1
for(i in 1:256){
if(array[i]>UCL|array[i]<LCL){
defect[u]=i
u<-u+1
}
}
defect
The windows that are out of control are "2 25 80 117 118 121 122 123 136 152". These indices are obtained form the x bar control chart and the indices mentioned previosly are obtained as a result of out of control situations.
Below the indices of each window in the first defective image can be seen. 117 118 119 120 121 122 123 are the window indices we expect to see the defect.
First Image and Indices:
gridpicture1<-readJPEG("~/Desktop/grid1.jpg")
plot(NA,xlim=c(0,nrow(gridpicture1)),ylim=c(0,ncol(gridpicture1)))
rasterImage(gridpicture1,0,0,nrow(gridpicture1),ncol(gridpicture1))
IMAGE 2
library(jpeg)
library(wvtool)
img2<-readJPEG("~/Desktop/Fabric2.jpg")
greyimg2<-img2[,,1]
filtered_image2<-gabor.filter(greyimg2,30,0,3,0,1,TRUE)
array2<-rep(NA)
newimage2<-filtered_image2$filtered_img
for(i in 1:16){
for(j in 1:16){
array2[(i-1)*16+j]=mean(newimage2[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array2)
UCL<-CL+2*sd(array2)
LCL<-CL-2*sd(array2)
plot(array2, type="l",ylim = c(min(array2),max(array2)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
defect2<-rep(0)
u<-1
for(i in 1:256){
if(array2[i]>UCL|array2[i]<LCL){
defect2[u]=i
u<-u+1
}
}
defect2
gridpicture2<-readJPEG("~/Desktop/grid2.jpg")
plot(NA,xlim=c(0,nrow(gridpicture2)),ylim=c(0,ncol(gridpicture2)))
rasterImage(gridpicture2,0,0,nrow(gridpicture2),ncol(gridpicture2))
IMAGE 3
library(jpeg)
library(wvtool)
img3<-readJPEG("~/Desktop/Fabric3.jpg")
greyimg3<-img3[,,1]
filtered_image3<-gabor.filter(greyimg3,30,0,3,0,1,TRUE)
array3<-rep(NA)
newimage3<-filtered_image3$filtered_img
for(i in 1:16){
for(j in 1:16){
array3[(i-1)*16+j]=mean(newimage3[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array3)
UCL<-CL+2*sd(array3)
LCL<-CL-2*sd(array3)
plot(array3, type="l",ylim = c(min(array3),max(array3)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
defect3<-rep(0)
u<-1
for(i in 1:256){
if(array3[i]>UCL|array3[i]<LCL){
defect3[u]=i
u<-u+1
}
}
defect3
gridpicture3<-readJPEG("~/Desktop/grid3.jpg")
plot(NA,xlim=c(0,nrow(gridpicture3)),ylim=c(0,ncol(gridpicture3)))
rasterImage(gridpicture3,0,0,nrow(gridpicture3),ncol(gridpicture3))
IMAGE 4
library(jpeg)
library(wvtool)
img4<-readJPEG("~/Desktop/Fabric4.jpg")
greyimg4<-img4[,,1]
filtered_image4<-gabor.filter(greyimg4,30,0,3,0,1,TRUE)
array4<-rep(NA)
newimage4<-filtered_image4$filtered_img
for(i in 1:16){
for(j in 1:16){
array4[(i-1)*16+j]=mean(newimage4[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array4)
UCL<-CL+2*sd(array4)
LCL<-CL-2*sd(array4)
defect4<-rep(0)
u<-1
for(i in 1:256){
if(array4[i]>UCL|array4[i]<LCL){
defect4[u]=i
u<-u+1
}
}
defect4
plot(array4, type="l",ylim = c(min(array4),max(array4)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture4<-readJPEG("~/Desktop/grid4.jpg")
plot(NA,xlim=c(0,nrow(gridpicture4)),ylim=c(0,ncol(gridpicture4)))
rasterImage(gridpicture4,0,0,nrow(gridpicture4),ncol(gridpicture4))
IMAGE 5
library(jpeg)
library(wvtool)
img5<-readJPEG("~/Desktop/Fabric5.jpg")
greyimg5<-img5[,,1]
filtered_image5<-gabor.filter(greyimg5,30,90,3,0,1,TRUE)
array5<-rep(NA)
newimage5<-filtered_image5$filtered_img
for(i in 1:16){
for(j in 1:16){
array5[(i-1)*16+j]=mean(newimage5[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array5)
UCL<-CL+2*sd(array5)
LCL<-CL-2*sd(array5)
defect5<-rep(0)
u<-1
for(i in 1:256){
if(array5[i]>UCL|array5[i]<LCL){
defect5[u]=i
u<-u+1
}
}
defect5
plot(array5, type="l",ylim = c(min(array5),max(array5)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture5<-readJPEG("~/Desktop/grid5.jpg")
plot(NA,xlim=c(0,nrow(gridpicture5)),ylim=c(0,ncol(gridpicture5)))
rasterImage(gridpicture5,0,0,nrow(gridpicture5),ncol(gridpicture5))
IMAGE 6
library(jpeg)
library(wvtool)
img6<-readJPEG("~/Desktop/Fabric6.jpg")
greyimg6<-img6[,,1]
filtered_image6<-gabor.filter(greyimg6,30,90,3,0,1,TRUE)
array6<-rep(NA)
newimage6<-filtered_image6$filtered_img
for(i in 1:16){
for(j in 1:16){
array6[(i-1)*16+j]=mean(newimage6[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array6)
UCL<-CL+2*sd(array6)
LCL<-CL-2*sd(array6)
defect6<-rep(0)
u<-1
for(i in 1:256){
if(array6[i]>UCL|array6[i]<LCL){
defect6[u]=i
u<-u+1
}
}
defect6
plot(array6, type="l",ylim = c(min(array6),max(array6)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture6<-readJPEG("~/Desktop/grid6.jpg")
plot(NA,xlim=c(0,nrow(gridpicture6)),ylim=c(0,ncol(gridpicture6)))
rasterImage(gridpicture6,0,0,nrow(gridpicture6),ncol(gridpicture6))
IMAGE 7
library(jpeg)
library(wvtool)
img7<-readJPEG("~/Desktop/Fabric7.jpg")
greyimg7<-img7[,,1]
filtered_image7<-gabor.filter(greyimg7,30,90,3,0,1,TRUE)
array7<-rep(NA)
newimage7<-filtered_image7$filtered_img
for(i in 1:16){
for(j in 1:16){
array7[(i-1)*16+j]=mean(newimage7[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array7)
UCL<-CL+2*sd(array7)
LCL<-CL-2*sd(array7)
defect7<-rep(0)
u<-1
for(i in 1:256){
if(array7[i]>UCL|array7[i]<LCL){
defect7[u]=i
u<-u+1
}
}
defect7
plot(array7, type="l",ylim = c(min(array7),max(array7)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture7<-readJPEG("~/Desktop/grid7.jpg")
plot(NA,xlim=c(0,nrow(gridpicture7)),ylim=c(0,ncol(gridpicture7)))
rasterImage(gridpicture7,0,0,nrow(gridpicture7),ncol(gridpicture7))
IMAGE 8
library(jpeg)
library(wvtool)
img8<-readJPEG("~/Desktop/Fabric8.jpg")
greyimg8<-img8[,,1]
filtered_image8<-gabor.filter(greyimg8,30,90,3,0,1,TRUE)
array8<-rep(NA)
newimage8<-filtered_image8$filtered_img
for(i in 1:16){
for(j in 1:16){
array8[(i-1)*16+j]=mean(newimage8[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array8)
UCL<-CL+2*sd(array8)
LCL<-CL-2*sd(array8)
defect8<-rep(0)
u<-1
for(i in 1:256){
if(array8[i]>UCL|array8[i]<LCL){
defect8[u]=i
u<-u+1
}
}
defect8
plot(array8, type="l",ylim = c(min(array8),max(array8)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture8<-readJPEG("~/Desktop/grid8.jpg")
plot(NA,xlim=c(0,nrow(gridpicture8)),ylim=c(0,ncol(gridpicture8)))
rasterImage(gridpicture8,0,0,nrow(gridpicture8),ncol(gridpicture8))
IMAGE 9
library(jpeg)
library(wvtool)
img9<-readJPEG("~/Desktop/Fabric9.jpg")
greyimg9<-img9[,,1]
filtered_image9<-gabor.filter(greyimg9,30,90,3,0,1,TRUE)
array9<-rep(NA)
newimage9<-filtered_image9$filtered_img
for(i in 1:16){
for(j in 1:16){
array9[(i-1)*16+j]=mean(newimage9[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array9)
UCL<-CL+2*sd(array9)
LCL<-CL-2*sd(array9)
defect9<-rep(0)
u<-1
for(i in 1:256){
if(array9[i]>UCL|array9[i]<LCL){
defect9[u]=i
u<-u+1
}
}
defect9
plot(array9, type="l",ylim = c(min(array9),max(array9)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture9<-readJPEG("~/Desktop/grid9.jpg")
plot(NA,xlim=c(0,nrow(gridpicture9)),ylim=c(0,ncol(gridpicture9)))
rasterImage(gridpicture9,0,0,nrow(gridpicture9),ncol(gridpicture9))
IMAGE 10
library(jpeg)
library(wvtool)
img10<-readJPEG("~/Desktop/Fabric10.jpg")
greyimg10<-img10[,,1]
filtered_image10<-gabor.filter(greyimg10,15,90,4,0,1,TRUE)
array10<-rep(NA)
newimage10<-filtered_image10$filtered_img
for(i in 1:16){
for(j in 1:16){
array10[(i-1)*16+j]=mean(newimage10[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array10)
UCL<-CL+2*sd(array10)
LCL<-CL-2*sd(array10)
defect10<-rep(0)
u<-1
for(i in 1:256){
if(array10[i]>UCL|array10[i]<LCL){
defect10[u]=i
u<-u+1
}
}
defect10
plot(array10, type="l",ylim = c(min(array10),max(array10)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture10<-readJPEG("~/Desktop/grid10.jpg")
plot(NA,xlim=c(0,nrow(gridpicture10)),ylim=c(0,ncol(gridpicture10)))
rasterImage(gridpicture10,0,0,nrow(gridpicture10),ncol(gridpicture10))
IMAGE 11
library(jpeg)
library(wvtool)
img11<-readJPEG("~/Desktop/Fabric11.jpg")
greyimg11<-img11[,,1]
filtered_image11<-gabor.filter(greyimg11,30,0,4,0,1,TRUE)
array11<-rep(NA)
newimage11<-filtered_image11$filtered_img
for(i in 1:16){
for(j in 1:16){
array11[(i-1)*16+j]=mean(newimage11[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array11)
UCL<-CL+2*sd(array11)
LCL<-CL-2*sd(array11)
defect11<-rep(0)
u<-1
for(i in 1:256){
if(array11[i]>UCL|array11[i]<LCL){
defect11[u]=i
u<-u+1
}
}
defect11
plot(array11, type="l",ylim = c(min(array11),max(array11)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture11<-readJPEG("~/Desktop/grid11.jpg")
plot(NA,xlim=c(0,nrow(gridpicture11)),ylim=c(0,ncol(gridpicture11)))
rasterImage(gridpicture11,0,0,nrow(gridpicture11),ncol(gridpicture11))
IMAGE 12
library(jpeg)
library(wvtool)
img12<-readJPEG("~/Desktop/Fabric12.jpg")
greyimg12<-img12[,,1]
filtered_image12<-gabor.filter(greyimg12,30,0,5,0,1,TRUE)
array12<-rep(NA)
newimage12<-filtered_image12$filtered_img
for(i in 1:16){
for(j in 1:16){
array12[(i-1)*16+j]=mean(newimage12[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array12)
UCL<-CL+2*sd(array12)
LCL<-CL-2*sd(array12)
defect12<-rep(0)
u<-1
for(i in 1:256){
if(array12[i]>UCL|array12[i]<LCL){
defect12[u]=i
u<-u+1
}
}
defect12
plot(array12, type="l",ylim = c(min(array12),max(array12)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture12<-readJPEG("~/Desktop/grid12.jpg")
plot(NA,xlim=c(0,nrow(gridpicture12)),ylim=c(0,ncol(gridpicture12)))
rasterImage(gridpicture12,0,0,nrow(gridpicture12),ncol(gridpicture12))
IMAGE 13
library(jpeg)
library(wvtool)
img13<-readJPEG("~/Desktop/Fabric13.jpg")
greyimg13<-img13[,,1]
filtered_image13<-gabor.filter(greyimg13,30,0,5,0,1,TRUE)
array13<-rep(NA)
newimage13<-filtered_image13$filtered_img
for(i in 1:16){
for(j in 1:16){
array13[(i-1)*16+j]=mean(newimage13[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array13)
UCL<-CL+2*sd(array13)
LCL<-CL-2*sd(array13)
defect13<-rep(0)
u<-1
for(i in 1:256){
if(array13[i]>UCL|array13[i]<LCL){
defect13[u]=i
u<-u+1
}
}
defect13
plot(array13, type="l",ylim = c(min(array13),max(array13)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture13<-readJPEG("~/Desktop/grid13.jpg")
plot(NA,xlim=c(0,nrow(gridpicture13)),ylim=c(0,ncol(gridpicture13)))
rasterImage(gridpicture13,0,0,nrow(gridpicture13),ncol(gridpicture13))
IMAGE 14
library(jpeg)
library(wvtool)
img14<-readJPEG("~/Desktop/Fabric14.jpg")
greyimg14<-img14[,,1]
filtered_image14<-gabor.filter(greyimg14,30,0,5,0,1,TRUE)
array14<-rep(NA)
newimage14<-filtered_image14$filtered_img
for(i in 1:16){
for(j in 1:16){
array14[(i-1)*16+j]=mean(newimage14[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array14)
UCL<-CL+2*sd(array14)
LCL<-CL-2*sd(array14)
defect14<-rep(0)
u<-1
for(i in 1:256){
if(array14[i]>UCL|array14[i]<LCL){
defect14[u]=i
u<-u+1
}
}
defect14
plot(array14, type="l",ylim = c(min(array14),max(array14)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture14<-readJPEG("~/Desktop/grid14.jpg")
plot(NA,xlim=c(0,nrow(gridpicture14)),ylim=c(0,ncol(gridpicture14)))
rasterImage(gridpicture14,0,0,nrow(gridpicture14),ncol(gridpicture14))
library(jpeg)
library(wvtool)
img15<-readJPEG("~/Desktop/Fabric15.jpg")
greyimg15<-img15[,,1]
filtered_image15<-gabor.filter(greyimg15,30,90,5,0,1,TRUE)
array15<-rep(NA)
newimage15<-filtered_image15$filtered_img
for(i in 1:16){
for(j in 1:16){
array15[(i-1)*16+j]=mean(newimage15[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array15)
UCL<-CL+2*sd(array15)
LCL<-CL-2*sd(array15)
defect15<-rep(0)
u<-1
for(i in 1:256){
if(array15[i]>UCL|array15[i]<LCL){
defect15[u]=i
u<-u+1
}
}
defect15
plot(array15, type="l",ylim = c(min(array15),max(array15)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture15<-readJPEG("~/Desktop/grid15.jpg")
plot(NA,xlim=c(0,nrow(gridpicture15)),ylim=c(0,ncol(gridpicture15)))
rasterImage(gridpicture15,0,0,nrow(gridpicture15),ncol(gridpicture15))
IMAGE 16
library(jpeg)
library(wvtool)
img16<-readJPEG("~/Desktop/Fabric16.jpg")
greyimg16<-img16[,,1]
filtered_image16<-gabor.filter(greyimg16,30,90,5,0,1,TRUE)
array16<-rep(NA)
newimage16<-filtered_image16$filtered_img
for(i in 1:16){
for(j in 1:16){
array16[(i-1)*16+j]=mean(newimage16[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array16)
UCL<-CL+2*sd(array16)
LCL<-CL-2*sd(array16)
defect16<-rep(0)
u<-1
for(i in 1:256){
if(array16[i]>UCL|array16[i]<LCL){
defect16[u]=i
u<-u+1
}
}
defect16
plot(array16, type="l",ylim = c(min(array16),max(array16)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture16<-readJPEG("~/Desktop/grid16.jpg")
plot(NA,xlim=c(0,nrow(gridpicture16)),ylim=c(0,ncol(gridpicture16)))
rasterImage(gridpicture16,0,0,nrow(gridpicture16),ncol(gridpicture16))
IMAGE 17
library(jpeg)
library(wvtool)
img17<-readJPEG("~/Desktop/Fabric17.jpg")
greyimg17<-img17[,,1]
filtered_image17<-gabor.filter(greyimg17,30,90,5,0,1,TRUE)
array17<-rep(NA)
newimage17<-filtered_image17$filtered_img
for(i in 1:16){
for(j in 1:16){
array17[(i-1)*16+j]=mean(newimage17[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array17)
UCL<-CL+2*sd(array17)
LCL<-CL-2*sd(array17)
defect17<-rep(0)
u<-1
for(i in 1:256){
if(array17[i]>UCL|array17[i]<LCL){
defect17[u]=i
u<-u+1
}
}
defect17
plot(array17, type="l",ylim = c(min(array17),max(array17)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture17<-readJPEG("~/Desktop/grid17.jpg")
plot(NA,xlim=c(0,nrow(gridpicture17)),ylim=c(0,ncol(gridpicture17)))
rasterImage(gridpicture17,0,0,nrow(gridpicture17),ncol(gridpicture17))
library(jpeg)
library(wvtool)
img18<-readJPEG("~/Desktop/Fabric18.jpg")
greyimg18<-img18[,,1]
filtered_image18<-gabor.filter(greyimg18,30,90,5,0,1,TRUE)
array18<-rep(NA)
newimage18<-filtered_image18$filtered_img
for(i in 1:16){
for(j in 1:16){
array18[(i-1)*16+j]=mean(newimage18[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array18)
UCL<-CL+2*sd(array18)
LCL<-CL-2*sd(array18)
defect18<-rep(0)
u<-1
for(i in 1:256){
if(array18[i]>UCL|array18[i]<LCL){
defect18[u]=i
u<-u+1
}
}
defect18
plot(array18, type="l",ylim = c(min(array18),max(array18)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
gridpicture18<-readJPEG("~/Desktop/grid18.jpg")
plot(NA,xlim=c(0,nrow(gridpicture18)),ylim=c(0,ncol(gridpicture18)))
rasterImage(gridpicture18,0,0,nrow(gridpicture18),ncol(gridpicture18))
IMAGE 19
library(jpeg)
library(wvtool)
img19<-readJPEG("~/Desktop/Fabric19.jpg")
greyimg19<-img19[,,1]
filtered_image19<-gabor.filter(greyimg19,30,90,5,0,1,TRUE)
array19<-rep(NA)
newimage19<-filtered_image19$filtered_img
for(i in 1:16){
for(j in 1:16){
array19[(i-1)*16+j]=mean(newimage19[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array19)
UCL<-CL+2*sd(array19)
LCL<-CL-2*sd(array19)
plot(array19, type="l",ylim = c(min(array19),max(array19)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
defect19<-rep(0)
u<-1
for(i in 1:256){
if(array19[i]>UCL|array19[i]<LCL){
defect19[u]=i
u<-u+1
}
}
defect19
gridpicture19<-readJPEG("~/Desktop/grid19.jpg")
plot(NA,xlim=c(0,nrow(gridpicture19)),ylim=c(0,ncol(gridpicture19)))
rasterImage(gridpicture19,0,0,nrow(gridpicture19),ncol(gridpicture19))
IMAGE 20
library(jpeg)
library(wvtool)
img20<-readJPEG("~/Desktop/Fabric20.jpg")
greyimg20<-img20[,,1]
filtered_image20<-gabor.filter(greyimg20,30,90,5,0,1,TRUE)
array20<-rep(NA)
newimage20<-filtered_image20$filtered_img
for(i in 1:16){
for(j in 1:16){
array20[(i-1)*16+j]=mean(newimage20[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(array20)
UCL<-CL+2*sd(array20)
LCL<-CL-2*sd(array20)
plot(array20, type="l",ylim = c(min(array20),max(array20)))
abline(CL,0, col="red")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
defect20<-rep(0)
u<-1
for(i in 1:256){
if(array20[i]>UCL|array20[i]<LCL){
defect20[u]=i
u<-u+1
}
}
defect20
gridpicture20<-readJPEG("~/Desktop/grid20.jpg")
plot(NA,xlim=c(0,nrow(gridpicture19)),ylim=c(0,ncol(gridpicture20)))
rasterImage(gridpicture20,0,0,nrow(gridpicture20),ncol(gridpicture20))
To sum up, linen is a very common material that is used in textile industry so it requires a precise quality control.In Industry there are several ways to inspect linen and find defects. In this project, Gabor Transformation followed by a 32x32 mean control on patches was conducted. Applying Gabor Transform with 0 and 90 degree resulted in a satisfactory but not perfect visualization of defects. After transform with 0 theta degrees to horizontal defects and 90 degrees to vertical defects, defects become more apparent and isolated. A better approach to this can be done by trying alternative theta values and selecting the best of it. Since 20 photos are unsatisfactory to find an optimal method to select theta, this approach was not taken however with more data and more theoretical knowledge, selecting an optimum theta for individual textures would work better. Also a better approach can be done by alternating other parameters of the Gabor Transform.
After the transform patches taken with size 32x32, 2 and 3 sigma limits were checked and after observations, 2 sigma limits selected as a better approach since 3 sigma is sometimes too large to reject defective portions. As can be seen from the control charts, some patches lie outside of the limit and these patches are where the defective portions lie in linen.
BIBLIOGRAPHY
Mahajan, Patil and Kolhe. “A review of automatic fabric defect detection techniques”,2009, “https://www.researchgate.net/publication/47372876_A_review_of_automatic_fabric_defect_detection_techniques”
H.Y.T. Ngan et al. “Image and Vision Computing” ,2011, BAĞKUR, Savaş. “FABRIC DEFECT DETECTION USING IMAGE PROCESSING TECHNIQUES.” Acikerisim.deu.edu.tr/, Jan. 2013, acikerisim.deu.edu.tr:8080/xmlui/bitstream/handle/20.500.12397/7599/328475.pdf?sequence=1&isAllowed=y.
“About Linen.” MagicLinen, magiclinen.com/about-linen.
Tong, Le, et al. “Fabric Defect Detection for Apparel Industry: A Nonlocal Sparse Representation Approach.” Fabric Defect Detection for Apparel Industry: A Nonlocal Sparse Representation Approach - IEEE Journals & Magazine, 2017, ieeexplore.ieee.org/document/7857011.
“Gabor.filter.” Function | R Documentation, www.rdocumentation.org/packages/wvtool/versions/1.0/topics/gabor.filter.
Benito, Mónica, and Daniel Peña. “Detecting Defects with Image Data.” ScienceDirect, 2007, halweb.uc3m.es/esp/Personal/personas/dpena/publications/ingles/2007CSDA_benito.pdf.
APPENDIX
Appendix I: R code for Gabor Filter: gabor.filter(x, lamda=5, theta=45, bw=1.5, phi=0, asp=1, disp=FALSE)
Lambda (λ) : Lambda represents the wavelength of the cosine factor of Gabor kernel filter. The value is provided in pixels. λ should be greater than 2. Theta (θ): Theta is the angle in which the Gabor function is applied. The value is specified in degrees. Bandwidth (b): Half response frequency bandwidth is a representation of Gabor filter. This is a ratio related to the ratio of σ / λ. Phase offset (φ): The phase offset it the cosine factor of the Gabor function. The value is given is degrees. The values 0 and 180 represent center symmetric functions whereas -90 and 90 degrees represents anti-symmetric functions. Aspect ratio (γ): Aspect ratio defines the ellipticity of the Gabor function. When γ is equal to one the support is circular. (Gabor.filter)